package com.chis.testConvert;

import com.chis.jm.bean.JxcSynBean;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wlj
 * @version 2019年03月21日
 * @Description
 * @Company zwx
 */
public class Test {
    public static void main(String[] args) {

//        getSn();
        getUnit();
    }

    public static void getUnit(){
        File file1 = new File("C:\\Users\\Administrator\\Desktop\\冷链高频数据\\test.log");
        FileReader m = null;
        try {
            m = new FileReader(file1);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        BufferedReader reader = new BufferedReader(m);
        Map<String,String> snmap = new LinkedHashMap<>();
        while (true) {
            String nextline = null;
            try {
                nextline = reader.readLine();
                if (nextline != null && nextline.length() > 8) {
                    String[] sbn = nextline.split(",");
                    snmap.put(sbn[1],sbn[0]);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (nextline == null) break;
        }


        Map<String,String> unitmap = new HashMap<>();
        try {
            FileInputStream fis = new FileInputStream("C:\\Users\\Administrator\\Desktop\\冷链高频数据\\test1.log");
            InputStreamReader isr = new InputStreamReader(fis, "UTF-8");
            BufferedReader br = new BufferedReader(isr);
            String nextline = null;
            while ((nextline = br.readLine()) != null) {
                if (nextline != null && nextline.length() > 8) {
                    String[] unit = nextline.split(",");
                    unitmap.put(unit[0],unit[1]);
                }
            }
        } catch (Exception e){
            e.printStackTrace();
        }


        for(String s : snmap.keySet()){
            if(unitmap.containsKey(s)){
                System.out.println(unitmap.get(s)+"##"+s+"##"+snmap.get(s));

            } else {
                System.out.println("ddd##"+s+"##"+snmap.get(s));
            }
        }

    }

    public static void getSn() {
        File file1 = new File("C:\\Users\\Administrator\\Desktop\\冷链高频数据\\test.log");
        FileReader m = null;
        try {
            m = new FileReader(file1);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        BufferedReader reader = new BufferedReader(m);
        StringBuilder sb = new StringBuilder();
        while (true) {
            String nextline = null;
            try {
                nextline = reader.readLine();
                if (nextline != null && nextline.length() > 8) {
                    String[] s = nextline.split(",");
                    sb.append(s[1]).append("','");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (nextline == null) break;
        }
        System.out.println(sb.toString());
    }


}
